package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import java.util.Date;
import java.util.List;
import javax.persistence.FetchType;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class PurchaseOrder implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String poNumber;
    private Double cost;            //cost for product
    private Double shippingCost;    //cost for shipping 
    private Double totalAmount;     //cost + shipping cost
    private String status;
    @Temporal(value = TemporalType.DATE)
    private Date poDate;
    private String remark;
  
    @OneToOne(cascade = {CascadeType.PERSIST}, fetch=FetchType.EAGER)
    private Address billingAddress;
    @OneToOne(cascade = {CascadeType.PERSIST}, fetch=FetchType.EAGER)
    private Customer customer;
   @OneToMany(cascade = {CascadeType.ALL}, fetch=FetchType.EAGER)
    private List<PurchaseItem> purchaseItems;
    private Double creditRate;
    private Double firstPayment;

    public PurchaseOrder() {
    }

    public PurchaseOrder(String poNumber, Double totalAmount,Double cost,Double shippingCost, String status, Date poDate, String remark, Address billingAddress, Customer customer, List<PurchaseItem> purchaseItems, Double creditRate, Double firstPayment) {
        this.totalAmount = totalAmount;
        this.status = status;
        this.poDate = poDate;
        this.remark = remark;
        this.cost = cost;
        this.shippingCost = shippingCost;
        this.billingAddress = billingAddress;
        this.customer = customer;
        this.purchaseItems = purchaseItems;
        this.poNumber = poNumber;
        this.creditRate = creditRate;
        this.firstPayment = firstPayment;

    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the totalAmount
     */
    public Double getTotalAmount() {
        return totalAmount;
    }

    /**
     * @param totalAmount the totalAmount to set
     */
    public void setTotalAmount(Double totalAmount) {
        this.totalAmount = totalAmount;
    }

    /**
     * @return the status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }



    /**
     * @return the remark
     */
    public String getRemark() {
        return remark;
    }

    /**
     * @param remark the remark to set
     */
    public void setRemark(String remark) {
        this.remark = remark;
    }

 

    /**
     * @return the billingAddress
     */
    public Address getBillingAddress() {
        return billingAddress;
    }

    /**
     * @param billingAddress the billingAddress to set
     */
    public void setBillingAddress(Address billingAddress) {
        this.billingAddress = billingAddress;
    }

    /**
     * @return the customer
     */
    public Customer getCustomer() {
        return customer;
    }

    /**
     * @param customer the customer to set
     */
    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    /**
     * @return the purchaseItems
     */
    public List<PurchaseItem> getPurchaseItems() {
        return purchaseItems;
    }

    /**
     * @param purchaseItems the purchaseItems to set
     */
    public void setPurchaseItems(List<PurchaseItem> purchaseItems) {
        this.purchaseItems = purchaseItems;
    }

    /**
     * @return the poDate
     */
    public Date getPoDate() {
        return poDate;
    }

    /**
     * @param poDate the poDate to set
     */
    public void setPoDate(Date poDate) {
        this.poDate = poDate;
    }

    /**
     * @return the poNumber
     */
    public String getPoNumber() {
        return poNumber;
    }

    /**
     * @param poNumber the poNumber to set
     */
    public void setPoNumber(String poNumber) {
        this.poNumber = poNumber;
    }

    /**
     * @return the creditRate
     */
    public Double getCreditRate() {
        return creditRate;
    }

    /**
     * @param creditRate the creditRate to set
     */
    public void setCreditRate(Double creditRate) {
        this.creditRate = creditRate;
    }

    /**
     * @return the firstPayment
     */
    public Double getFirstPayment() {
        return firstPayment;
    }

    /**
     * @param firstPayment the firstPayment to set
     */
    public void setFirstPayment(Double firstPayment) {
        this.firstPayment = firstPayment;
    }

    /**
     * @return the cost
     */
    public Double getCost() {
        return cost;
    }

    /**
     * @param cost the cost to set
     */
    public void setCost(Double cost) {
        this.cost = cost;
    }

    /**
     * @return the shippingcost
     */
    public Double getShippingCost() {
        return shippingCost;
    }

    /**
     * @param shippingcost the shippingCost to set
     */
    public void setShippingCost(Double shippingCost) {
        this.shippingCost = shippingCost;
    }
}
